using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.Common;
using System.Text;
using System.Text.RegularExpressions;
using Oracle.ManagedDataAccess.Types;
using OracleInternal.Common;
using OracleInternal.ServiceObjects;

namespace Oracle.ManagedDataAccess.Client
{
	public sealed class OracleCommandBuilder : DbCommandBuilder
	{
		private bool m_caseSensitive;

		private OracleRowUpdatingEventHandler m_handler;

		private OracleCommand m_deleteCmd;

		private OracleCommand m_insertCmd;

		private OracleCommand m_updateCmd;

		private ArrayList m_cachedInsertParams;

		private ArrayList m_cachedUpdateParams;

		private ArrayList m_cachedDeleteParams;

		private bool m_disposed;

		private static object m_dpLock = new object();

		private static OracleCommand m_dpCommand;

		private static OracleParameter[] m_dpCommandParams;

		private bool m_ODTDesignMode;

		private static int m_sMaxParamNameLen = 30;

		private const string QUOTE = "\"";

		private const string SCHEMA_SEPERATOR = ".";

		private SQLMetaData m_sqlMetaData;

		private int m_numberOfHiddenColumns;

		private const int NO_OF_PARAMS = 10;

		private const int NAME_IN = 0;

		private const int PARAM_COUNT_IN = 1;

		private const int PARAM_COUNT_OUT = 2;

		private const int PARAM_NAME_OUT = 3;

		private const int DIRECTION_OUT = 4;

		private const int ORADBTYPE_OUT = 5;

		private const int SIZE_OUT = 6;

		private const int TYPE_NAME_OUT = 7;

		private const int POSITION_OUT = 8;

		private const int DATA_LEVEL_OUT = 9;

		private const int ASSOC_TYPE_OUT = 10;

		private const int ASSOC_TYPE_NAME_OUT = 11;

		private const int ASSOC_TYPE_SIZE_OUT = 12;

		private const int PLSQL_TYPE_NAME_OUT = 13;

		private const int TYPE_SUBNAME_OUT = 14;

		private const int MAX_ARG_NAME_LENGTH = 128;

		private const int FIRST_FETCH_COUNT = 128;

		private const string DP_COMMAND_TEXT_12202_N_ABOVE = "DECLARE TYPE NUM_TABLE IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE STR_TABLE IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER; name_in          VARCHAR2(2000); param_count_in   PLS_INTEGER; link\t     \t      VARCHAR2(2000); context          NUMBER := 1; schema           VARCHAR2(2000); part1            VARCHAR2(2000); part2            VARCHAR2(2000); dblink           VARCHAR2(2000); part1_type       NUMBER; object_number    NUMBER; refcur\t          SYS_REFCURSOR; idx\t\t          PLS_INTEGER := 0; proc_count       PLS_INTEGER := 0; procrefcur\t      SYS_REFCURSOR; procobjectnames  ALL_PROCEDURES.OBJECT_NAME%TYPE ; typesubname         VARCHAR2(2000); oradbtype        VARCHAR2(2000); index_assocTypes PLS_INTEGER; has_plsqlArray   PLS_INTEGER; oradbtypeIndex   PLS_INTEGER; typesubnameIndex    PLS_INTEGER; typeofAssocArray PLS_INTEGER; elemTypeNameAssocArray VARCHAR2(2000); elemSizeAssocArray PLS_INTEGER; plsqlrefcur\t          SYS_REFCURSOR; param_count_out        PLS_INTEGER := 0; param_name_out         STR_TABLE; direction_out          NUM_TABLE; oradbtype_out          NUM_TABLE; size_out               NUM_TABLE; type_name_out          STR_TABLE; position_out           NUM_TABLE; data_level_out         NUM_TABLE; tableofAssocTypes_out  NUM_TABLE; tableofAssocTypeName_out STR_TABLE; tableofAssocSize_out   NUM_TABLE; plsql_type_name_out     STR_TABLE; type_subname_out        STR_TABLE; param_name_null_out    STR_TABLE; direction_null_out     NUM_TABLE; oradbtype_null_out     NUM_TABLE; size_null_out          NUM_TABLE; type_name_null_out     STR_TABLE; position_null_out      NUM_TABLE; data_level_null_out    NUM_TABLE; tableofAssocTypes_null_out NUM_TABLE; tableofAssocTypeName_null_out STR_TABLE; tableofAssocSize_null_out   NUM_TABLE; plsql_type_name_null_out     STR_TABLE; type_subname_null_out        STR_TABLE; BEGIN name_in := :1; param_count_in := :2; link := NULL; DBMS_UTILITY.NAME_RESOLVE( name_in, context, schema, part1, part2, dblink, part1_type, object_number); WHILE (dblink IS NOT NULL) LOOP link := '@' || dblink; name_in := NULL; IF (schema IS NOT NULL) THEN name_in := '\"' || schema || '\"' || '.'; END IF; IF (part1 IS NOT NULL) THEN name_in := name_in || '\"' || part1 || '\"' || '.'; END IF; IF (part2 IS NULL) THEN name_in := RTRIM(name_in, '.'); ELSE name_in := name_in || '\"' || part2 || '\"'; END IF; EXECUTE IMMEDIATE 'BEGIN DBMS_UTILITY.NAME_RESOLVE' || link || '(:1, :2, :3, :4, :5, :6, :7, :8); END;' USING name_in, context, OUT schema, OUT part1, OUT part2, OUT dblink, OUT part1_type, OUT object_number; END LOOP; IF (param_count_out = 0) THEN OPEN refcur FOR 'SELECT  DECODE (POSITION, 0, ''RETURN_VALUE'', ARGUMENT_NAME) param_name, DECODE(IN_OUT, ''IN'', \t  1,  ''IN/OUT'', 3, ''OUT'', DECODE(ARGUMENT_NAME, NULL, 6, 2), 1) direction, DECODE(DATA_TYPE, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(DATA_TYPE, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (TYPE_OWNER ||  DECODE(TYPE_OWNER, NULL, NULL, ''.'') ||  TYPE_NAME ) type_name, TYPE_SUBNAME typesubname, POSITION   position, DATA_LEVEL data_level FROM ALL_ARGUMENTS' || link || ' WHERE OWNER \t\t  = :1 \t  AND (PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND PACKAGE_NAME is null)) AND OBJECT_NAME \t  = :4 \t  AND NVL(overload, 1) = 1 ORDER BY SEQUENCE' USING schema, part1, part1, part2; FETCH refcur BULK COLLECT INTO param_name_out, direction_out, oradbtype_out, size_out, type_name_out, type_subname_out, position_out, data_level_out; param_count_out := refcur%ROWCOUNT; CLOSE refcur; END IF; IF (part1_type = 9 AND param_count_out = 0) THEN OPEN procrefcur FOR 'SELECT OBJECT_NAME FROM ALL_PROCEDURES' || link || ' WHERE OWNER = :1 AND (((OBJECT_NAME = :2) AND (PROCEDURE_NAME IS NULL)) OR ((OBJECT_NAME = :3) AND (PROCEDURE_NAME = :4)))' USING schema, part2, part1, part2; FETCH procrefcur INTO procobjectnames;proc_count := procrefcur%ROWCOUNT; CLOSE procrefcur; IF (proc_count = 0) THEN param_count_out := -1002; END IF; END IF; :3 := param_count_out; oradbtypeIndex := oradbtype_out.first; IF (oradbtypeIndex IS NOT NULL) THEN LOOP oradbtype := oradbtype_out(oradbtypeIndex); IF (oradbtype = 1) THEN has_plsqlArray := 1; END IF; oradbtypeIndex := oradbtype_out.next(oradbtypeIndex); EXIT WHEN (oradbtypeIndex IS NULL) OR (oradbtypeIndex >= param_count_out) OR (has_plsqlArray=1); END LOOP; END IF; IF (has_plsqlArray = 1) THEN OPEN plsqlrefcur FOR 'SELECT  DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (PLSQL_COLL_TYPES_SYN.ELEM_TYPE_OWNER ||  DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_OWNER, NULL, NULL, ''.'') ||  PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME ) type_name,  PLSQL_COLL_TYPES_SYN.TYPE_NAME typesubname FROM ALL_ARGUMENTS' || link || ' ARGUMENTS_SYN , ALL_PLSQL_COLL_TYPES' || link || ' PLSQL_COLL_TYPES_SYN  WHERE  ARGUMENTS_SYN.OWNER \t\t  = :1 \t  AND (ARGUMENTS_SYN.PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND ARGUMENTS_SYN.PACKAGE_NAME is null)) AND  ARGUMENTS_SYN.OBJECT_NAME \t  = :4 \t  AND  ARGUMENTS_SYN.TYPE_OWNER    = PLSQL_COLL_TYPES_SYN.OWNER AND  ARGUMENTS_SYN.TYPE_NAME     = PLSQL_COLL_TYPES_SYN.PACKAGE_NAME AND ARGUMENTS_SYN.TYPE_SUBNAME  = PLSQL_COLL_TYPES_SYN.TYPE_NAME ' USING schema, part1,part1,part2; FETCH plsqlrefcur BULK COLLECT INTO tableofAssocTypes_out, tableofAssocSize_out, tableofAssocTypeName_out, plsql_type_name_out; CLOSE plsqlrefcur; END IF; IF (param_count_out > param_count_in OR param_count_out < 0) THEN param_name_out := param_name_null_out; direction_out := direction_null_out; oradbtype_out := oradbtype_null_out; size_out      := size_null_out; type_name_out := type_name_null_out; position_out  := position_null_out; data_level_out := data_level_null_out; tableofAssocTypes_out := tableofAssocTypes_null_out; tableofAssocSize_out := tableofAssocTypes_null_out; tableofAssocTypeName_out := tableofAssocTypeName_null_out; plsql_type_name_out := plsql_type_name_null_out; type_subname_out := type_subname_null_out; END IF; :4 := param_name_out; :5 := direction_out; :6 := oradbtype_out; :7 := size_out; :8 := type_name_out; :9 := position_out; :10 := data_level_out; :11 := tableofAssocTypes_out; :12 := tableofAssocTypeName_out; :13 := tableofAssocSize_out; :14 := plsql_type_name_out; :15 := type_subname_out; END; ";

		private const string DP_COMMAND_TEXT_TILL_12201 = "DECLARE TYPE NUM_TABLE IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE STR_TABLE IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER; name_in          VARCHAR2(2000); param_count_in   PLS_INTEGER; link\t     \t      VARCHAR2(2000); context          NUMBER := 1; schema           VARCHAR2(2000); part1            VARCHAR2(2000); part2            VARCHAR2(2000); dblink           VARCHAR2(2000); part1_type       NUMBER; object_number    NUMBER; refcur\t          SYS_REFCURSOR; idx\t\t          PLS_INTEGER := 0; proc_count       PLS_INTEGER := 0; procrefcur\t      SYS_REFCURSOR; procobjectnames  ALL_PROCEDURES.OBJECT_NAME%TYPE ; param_count_out        PLS_INTEGER := 0; param_name_out         STR_TABLE; direction_out          NUM_TABLE; oradbtype_out          NUM_TABLE; size_out               NUM_TABLE; type_name_out          STR_TABLE; position_out           NUM_TABLE; data_level_out         NUM_TABLE; param_name_null_out    STR_TABLE; direction_null_out     NUM_TABLE; oradbtype_null_out     NUM_TABLE; size_null_out          NUM_TABLE; type_name_null_out     STR_TABLE; position_null_out      NUM_TABLE; data_level_null_out    NUM_TABLE; BEGIN name_in := :1; param_count_in := :2; link := NULL; DBMS_UTILITY.NAME_RESOLVE( name_in, context, schema, part1, part2, dblink, part1_type, object_number); WHILE (dblink IS NOT NULL) LOOP link := '@' || dblink; name_in := NULL; IF (schema IS NOT NULL) THEN name_in := '\"' || schema || '\"' || '.'; END IF; IF (part1 IS NOT NULL) THEN name_in := name_in || '\"' || part1 || '\"' || '.'; END IF; IF (part2 IS NULL) THEN name_in := RTRIM(name_in, '.'); ELSE name_in := name_in || '\"' || part2 || '\"'; END IF; EXECUTE IMMEDIATE 'BEGIN DBMS_UTILITY.NAME_RESOLVE' || link || '(:1, :2, :3, :4, :5, :6, :7, :8); END;' USING name_in, context, OUT schema, OUT part1, OUT part2, OUT dblink, OUT part1_type, OUT object_number; END LOOP; IF (param_count_out = 0) THEN OPEN refcur FOR 'SELECT  DECODE (POSITION, 0, ''RETURN_VALUE'', ARGUMENT_NAME) param_name, DECODE(IN_OUT, ''IN'', \t  1,  ''IN/OUT'', 3, ''OUT'', DECODE(ARGUMENT_NAME, NULL, 6, 2), 1) direction, DECODE(DATA_TYPE, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(DATA_TYPE, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (TYPE_OWNER ||  DECODE(TYPE_OWNER, NULL, NULL, ''.'') ||  TYPE_NAME ) type_name, POSITION   position, DATA_LEVEL data_level FROM ALL_ARGUMENTS' || link || ' WHERE OWNER \t\t  = :1 \t  AND (PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND PACKAGE_NAME is null)) AND OBJECT_NAME \t  = :4 \t  AND NVL(overload, 1) = 1 ORDER BY SEQUENCE' USING schema, part1, part1, part2; FETCH refcur BULK COLLECT INTO param_name_out, direction_out, oradbtype_out, size_out, type_name_out, position_out, data_level_out; param_count_out := refcur%ROWCOUNT; CLOSE refcur; END IF; IF (part1_type = 9 AND param_count_out = 0) THEN OPEN procrefcur FOR 'SELECT OBJECT_NAME FROM ALL_PROCEDURES' || link || ' WHERE OWNER = :1 AND (((OBJECT_NAME = :2) AND (PROCEDURE_NAME IS NULL)) OR ((OBJECT_NAME = :3) AND (PROCEDURE_NAME = :4)))' USING schema, part2, part1, part2; FETCH procrefcur INTO procobjectnames;proc_count := procrefcur%ROWCOUNT; CLOSE procrefcur; IF (proc_count = 0) THEN param_count_out := -1002; END IF; END IF; :3 := param_count_out; IF (param_count_out > param_count_in OR param_count_out < 0) THEN param_name_out:= param_name_null_out; direction_out := direction_null_out; oradbtype_out := oradbtype_null_out; size_out      := size_null_out; type_name_out := type_name_null_out; position_out  := position_null_out; data_level_out:= data_level_null_out; END IF; :4 := param_name_out; :5 := direction_out; :6 := oradbtype_out; :7 := size_out; :8 := type_name_out; :9 := position_out; :10:= data_level_out; END;";

		private bool ODTDesignMode
		{
			get
			{
				return m_ODTDesignMode;
			}
			set
			{
				m_ODTDesignMode = value;
			}
		}

		[DefaultValue(true)]
		[Description("")]
		public bool CaseSensitive
		{
			get
			{
				return m_caseSensitive;
			}
			set
			{
				m_caseSensitive = value;
			}
		}

		[DefaultValue(null)]
		[Description("")]
		public new OracleDataAdapter DataAdapter
		{
			get
			{
				return (OracleDataAdapter)base.DataAdapter;
			}
			set
			{
				if (DataAdapter != value)
				{
					if (DataAdapter != null)
					{
						DataAdapter.RowUpdating -= m_handler;
					}
					base.DataAdapter = value;
					if (DataAdapter != null)
					{
						m_disposed = false;
						DataAdapter.RowUpdating += m_handler;
					}
				}
			}
		}

		[DefaultValue("\"")]
		public override string QuoteSuffix
		{
			get
			{
				return "\"";
			}
			set
			{
			}
		}

		[DefaultValue(".")]
		public override string SchemaSeparator
		{
			get
			{
				return ".";
			}
			set
			{
				if (value != ".")
				{
					throw new NotSupportedException();
				}
			}
		}

		[DefaultValue("\"")]
		public override string QuotePrefix
		{
			get
			{
				return "\"";
			}
			set
			{
			}
		}

		public override CatalogLocation CatalogLocation
		{
			get
			{
				return CatalogLocation.End;
			}
			set
			{
				if (CatalogLocation.End != value)
				{
					throw new NotSupportedException();
				}
			}
		}

		public override string CatalogSeparator
		{
			get
			{
				return "@";
			}
			set
			{
				if ("@" != value)
				{
					throw new NotSupportedException();
				}
			}
		}

		public OracleCommandBuilder()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor);
			}
			try
			{
				m_caseSensitive = true;
				m_handler = RowUpdating;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor);
				}
			}
		}

		public OracleCommandBuilder(OracleDataAdapter dataAdapter)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor);
			}
			try
			{
				DataAdapter = dataAdapter;
				m_caseSensitive = true;
				m_handler = RowUpdating;
				if (dataAdapter != null)
				{
					dataAdapter.RowUpdating += m_handler;
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ctor);
				}
			}
		}

		public static void DeriveParameters(OracleCommand command)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.DeriveParameters);
			}
			try
			{
				if (command == null)
				{
					throw new ArgumentNullException("command");
				}
				if (command.CommandType != CommandType.StoredProcedure)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.ODP_NOT_SUPPORTED, "OracleCommandBuilder.DeriveParameters", command.CommandType.ToString()));
				}
				OracleConnection connection = command.Connection;
				if (connection == null || connection.m_connectionState != ConnectionState.Open)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.CON_CLOSED));
				}
				string commandText = command.CommandText;
				if (commandText == null || commandText.Length == 0)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.ODP_INVALID_VALUE, "OracleCommand.CommandText"));
				}
				DeriveParamInfo deriveParamInfo = null;
				SyncDictionary<string, DeriveParamInfoPool> dictDeriveParamInfoPool = connection.m_oracleConnectionImpl.m_pm.m_dictDeriveParamInfoPool;
				if (dictDeriveParamInfoPool != null && dictDeriveParamInfoPool.ContainsKey(connection.m_oracleConnectionImpl.ServiceName))
				{
					deriveParamInfo = dictDeriveParamInfoPool[connection.m_oracleConnectionImpl.ServiceName][commandText];
				}
				bool flag = ((command.Connection.m_majorVersion >= 18 || (command.Connection.m_majorVersion >= 12 && command.Connection.m_minorVersion >= 2 && command.Connection.m_oracleConnectionImpl != null && command.Connection.m_oracleConnectionImpl.m_dbPatchsetVersion >= 2)) ? true : false);
				if (deriveParamInfo == null)
				{
					bool flag2 = false;
					int num = 0;
					string[] paramNameArray = null;
					int[] directionArray = null;
					int[] oraDbTypeArray = null;
					int[] sizeArray = null;
					string[] typeNameArray = null;
					int[] positionArray = null;
					int[] dataLevelOutArray = null;
					int[] assocTypeArray = null;
					string[] assocTypeNameArray = null;
					string[] plsqlTypeNameArray = null;
					string[] typeSubNameArray = null;
					int[] assocTypeSizeArray = null;
					lock (m_dpLock)
					{
						if (dictDeriveParamInfoPool != null && dictDeriveParamInfoPool.ContainsKey(connection.m_oracleConnectionImpl.ServiceName))
						{
							deriveParamInfo = dictDeriveParamInfoPool[connection.m_oracleConnectionImpl.ServiceName][commandText];
						}
						if (deriveParamInfo == null)
						{
							SetUpDpCommand(command);
							m_dpCommand.ExecuteNonQuery();
							num = (int)m_dpCommandParams[2].Value;
							if (num == -1002)
							{
								throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.ODP_INVALID_VALUE, "OracleCommand.CommandText"));
							}
							if (num > 128)
							{
								m_dpCommandParams[1].Value = num;
								m_dpCommandParams[3].Size = num;
								if (m_dpCommandParams[3].ArrayBindSize.Length < num)
								{
									m_dpCommandParams[3].ArrayBindSize = new int[num];
								}
								for (int i = 0; i < num; i++)
								{
									m_dpCommandParams[3].ArrayBindSize[i] = 128;
								}
								m_dpCommandParams[4].Size = num;
								m_dpCommandParams[5].Size = num;
								m_dpCommandParams[6].Size = num;
								m_dpCommandParams[7].Size = num;
								if (m_dpCommandParams[7].ArrayBindSize.Length < num)
								{
									m_dpCommandParams[7].ArrayBindSize = new int[num];
								}
								for (int j = 0; j < num; j++)
								{
									m_dpCommandParams[7].ArrayBindSize[j] = 128;
								}
								m_dpCommandParams[8].Size = num;
								m_dpCommandParams[9].Size = num;
								if (flag)
								{
									m_dpCommandParams[10].Size = num;
									m_dpCommandParams[11].Size = num;
									m_dpCommandParams[13].Size = num;
									m_dpCommandParams[14].Size = num;
									if (m_dpCommandParams[11].ArrayBindSize.Length < num)
									{
										m_dpCommandParams[11].ArrayBindSize = new int[num];
									}
									if (m_dpCommandParams[13].ArrayBindSize.Length < num)
									{
										m_dpCommandParams[13].ArrayBindSize = new int[num];
									}
									if (m_dpCommandParams[14].ArrayBindSize.Length < num)
									{
										m_dpCommandParams[14].ArrayBindSize = new int[num];
									}
									for (int k = 0; k < num; k++)
									{
										m_dpCommandParams[11].ArrayBindSize[k] = 128;
										m_dpCommandParams[13].ArrayBindSize[k] = 128;
										m_dpCommandParams[14].ArrayBindSize[k] = 128;
									}
									m_dpCommandParams[12].Size = num;
								}
								m_dpCommand.ExecuteNonQuery();
								num = (int)m_dpCommandParams[2].Value;
							}
							paramNameArray = (string[])m_dpCommandParams[3].Value;
							directionArray = (int[])m_dpCommandParams[4].Value;
							oraDbTypeArray = (int[])m_dpCommandParams[5].Value;
							sizeArray = (int[])m_dpCommandParams[6].Value;
							typeNameArray = (string[])m_dpCommandParams[7].Value;
							positionArray = (int[])m_dpCommandParams[8].Value;
							dataLevelOutArray = (int[])m_dpCommandParams[9].Value;
							if (flag)
							{
								assocTypeArray = (int[])m_dpCommandParams[10].Value;
								assocTypeNameArray = (string[])m_dpCommandParams[11].Value;
								plsqlTypeNameArray = (string[])m_dpCommandParams[13].Value;
								typeSubNameArray = (string[])m_dpCommandParams[14].Value;
								assocTypeSizeArray = (int[])m_dpCommandParams[12].Value;
							}
							flag2 = true;
						}
					}
					if (flag2)
					{
						deriveParamInfo = new DeriveParamInfo(num);
						PopulateDeriveParamInfoFromDpCommandExecution(ref deriveParamInfo, command, flag, paramNameArray, directionArray, oraDbTypeArray, sizeArray, typeNameArray, positionArray, dataLevelOutArray, assocTypeArray, assocTypeNameArray, assocTypeSizeArray, plsqlTypeNameArray, typeSubNameArray);
						if (dictDeriveParamInfoPool != null)
						{
							if (!dictDeriveParamInfoPool.ContainsKey(connection.m_oracleConnectionImpl.ServiceName))
							{
								lock (connection.m_oracleConnectionImpl.m_pm.m_dictDeriveParamInfoPoolLock)
								{
									if (!dictDeriveParamInfoPool.ContainsKey(connection.m_oracleConnectionImpl.ServiceName))
									{
										dictDeriveParamInfoPool[connection.m_oracleConnectionImpl.ServiceName] = new DeriveParamInfoPool(50);
									}
								}
							}
							dictDeriveParamInfoPool[connection.m_oracleConnectionImpl.ServiceName][commandText] = deriveParamInfo;
						}
					}
				}
				lock (command)
				{
					PopulateCommandParamsFromDeriveParamInfo(command, deriveParamInfo);
				}
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.DeriveParameters, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.DeriveParameters);
				}
			}
		}

		private static void PopulateDeriveParamInfoFromDpCommandExecution(ref DeriveParamInfo deriveParamInfo, OracleCommand cmd, bool isDB12202nAbove, string[] paramNameArray, int[] directionArray, int[] oraDbTypeArray, int[] sizeArray, string[] typeNameArray, int[] positionArray, int[] dataLevelOutArray, int[] assocTypeArray, string[] assocTypeNameArray, int[] assocTypeSizeArray, string[] plsqlTypeNameArray, string[] typeSubNameArray)
		{
			int num = 0;
			for (int i = 0; i < deriveParamInfo.m_allocCount; i++)
			{
				if (dataLevelOutArray[i] != 0)
				{
					continue;
				}
				if (oraDbTypeArray[i] == 0)
				{
					break;
				}
				int num2 = positionArray[i];
				if (oraDbTypeArray[i] == 100)
				{
					if (typeNameArray[i] == "SYS.XMLTYPE" || typeNameArray[i] == "PUBLIC.XMLTYPE")
					{
						oraDbTypeArray[i] = 127;
					}
					else
					{
						oraDbTypeArray[i] = -1;
					}
				}
				if (oraDbTypeArray[i] == -1)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_PRM_NOT_SUPPORTED, num2.ToString()));
				}
				deriveParamInfo.m_paramName[num] = paramNameArray[i];
				deriveParamInfo.m_direction[num] = (ParameterDirection)directionArray[i];
				deriveParamInfo.m_size[num] = sizeArray[i];
				if (oraDbTypeArray[i] != 1)
				{
					deriveParamInfo.m_oraCollType[num] = OracleCollectionType.None;
					deriveParamInfo.m_oraDbType[num] = (OracleDbType)oraDbTypeArray[i];
				}
				else
				{
					deriveParamInfo.m_oraCollType[num] = OracleCollectionType.PLSQLAssociativeArray;
					if (isDB12202nAbove)
					{
						string value = typeSubNameArray[i];
						int num3 = Array.IndexOf(plsqlTypeNameArray, value);
						if (assocTypeArray != null && assocTypeNameArray != null && assocTypeSizeArray != null)
						{
							if (assocTypeArray[num3] == 100)
							{
								if (assocTypeNameArray[num3] == "SYS.XMLTYPE" || assocTypeNameArray[num3] == "PUBLIC.XMLTYPE")
								{
									assocTypeArray[num3] = 127;
								}
								else
								{
									assocTypeArray[num3] = -1;
								}
							}
							if (assocTypeArray[num3] == -1)
							{
								throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_PRM_NOT_SUPPORTED, num2.ToString()));
							}
							deriveParamInfo.m_oraDbType[num] = (OracleDbType)assocTypeArray[num3];
							deriveParamInfo.m_arrayBindSize[num] = assocTypeSizeArray[num3];
						}
					}
					else
					{
						i++;
						if (oraDbTypeArray[i] == 100)
						{
							if (typeNameArray[i] == "SYS.XMLTYPE" || typeNameArray[i] == "PUBLIC.XMLTYPE")
							{
								oraDbTypeArray[i] = 127;
							}
							else
							{
								oraDbTypeArray[i] = -1;
							}
						}
						if (oraDbTypeArray[i] == -1)
						{
							throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_PRM_NOT_SUPPORTED, num2.ToString()));
						}
						deriveParamInfo.m_oraDbType[num] = (OracleDbType)oraDbTypeArray[i];
						deriveParamInfo.m_arrayBindSize[num] = sizeArray[i];
					}
				}
				num++;
			}
			deriveParamInfo.m_paramCount = num;
		}

		private static void SetUpDpCommand(OracleCommand command)
		{
			bool flag = ((command.Connection.m_majorVersion >= 18 || (command.Connection.m_majorVersion >= 12 && command.Connection.m_minorVersion >= 2 && command.Connection.m_oracleConnectionImpl != null && command.Connection.m_oracleConnectionImpl.m_dbPatchsetVersion >= 2)) ? true : false);
			if (m_dpCommand == null)
			{
				m_dpCommand = new OracleCommand();
				int num = ((!flag) ? 10 : 15);
				m_dpCommandParams = new OracleParameter[num];
				for (int i = 0; i < num; i++)
				{
					m_dpCommandParams[i] = new OracleParameter();
					m_dpCommand.Parameters.Add(m_dpCommandParams[i]);
				}
				m_dpCommandParams[0].DbType = DbType.String;
				m_dpCommandParams[1].DbType = DbType.Int32;
				m_dpCommandParams[2].DbType = DbType.Int32;
				m_dpCommandParams[2].Direction = ParameterDirection.Output;
				m_dpCommandParams[3].DbType = DbType.String;
				m_dpCommandParams[3].Direction = ParameterDirection.Output;
				m_dpCommandParams[3].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[4].DbType = DbType.Int32;
				m_dpCommandParams[4].Direction = ParameterDirection.Output;
				m_dpCommandParams[4].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[5].DbType = DbType.Int32;
				m_dpCommandParams[5].Direction = ParameterDirection.Output;
				m_dpCommandParams[5].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[6].DbType = DbType.Int32;
				m_dpCommandParams[6].Direction = ParameterDirection.Output;
				m_dpCommandParams[6].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[7].DbType = DbType.String;
				m_dpCommandParams[7].Direction = ParameterDirection.Output;
				m_dpCommandParams[7].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[8].DbType = DbType.Int32;
				m_dpCommandParams[8].Direction = ParameterDirection.Output;
				m_dpCommandParams[8].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				m_dpCommandParams[9].DbType = DbType.Int32;
				m_dpCommandParams[9].Direction = ParameterDirection.Output;
				m_dpCommandParams[9].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				if (flag)
				{
					m_dpCommandParams[10].DbType = DbType.Int32;
					m_dpCommandParams[10].Direction = ParameterDirection.Output;
					m_dpCommandParams[10].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
					m_dpCommandParams[11].DbType = DbType.String;
					m_dpCommandParams[11].Direction = ParameterDirection.Output;
					m_dpCommandParams[11].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
					m_dpCommandParams[12].DbType = DbType.Int32;
					m_dpCommandParams[12].Direction = ParameterDirection.Output;
					m_dpCommandParams[12].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
					m_dpCommandParams[13].DbType = DbType.String;
					m_dpCommandParams[13].Direction = ParameterDirection.Output;
					m_dpCommandParams[13].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
					m_dpCommandParams[14].DbType = DbType.String;
					m_dpCommandParams[14].Direction = ParameterDirection.Output;
					m_dpCommandParams[14].CollectionType = OracleCollectionType.PLSQLAssociativeArray;
				}
			}
			if (flag)
			{
				m_dpCommand.CommandText = "DECLARE TYPE NUM_TABLE IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE STR_TABLE IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER; name_in          VARCHAR2(2000); param_count_in   PLS_INTEGER; link\t     \t      VARCHAR2(2000); context          NUMBER := 1; schema           VARCHAR2(2000); part1            VARCHAR2(2000); part2            VARCHAR2(2000); dblink           VARCHAR2(2000); part1_type       NUMBER; object_number    NUMBER; refcur\t          SYS_REFCURSOR; idx\t\t          PLS_INTEGER := 0; proc_count       PLS_INTEGER := 0; procrefcur\t      SYS_REFCURSOR; procobjectnames  ALL_PROCEDURES.OBJECT_NAME%TYPE ; typesubname         VARCHAR2(2000); oradbtype        VARCHAR2(2000); index_assocTypes PLS_INTEGER; has_plsqlArray   PLS_INTEGER; oradbtypeIndex   PLS_INTEGER; typesubnameIndex    PLS_INTEGER; typeofAssocArray PLS_INTEGER; elemTypeNameAssocArray VARCHAR2(2000); elemSizeAssocArray PLS_INTEGER; plsqlrefcur\t          SYS_REFCURSOR; param_count_out        PLS_INTEGER := 0; param_name_out         STR_TABLE; direction_out          NUM_TABLE; oradbtype_out          NUM_TABLE; size_out               NUM_TABLE; type_name_out          STR_TABLE; position_out           NUM_TABLE; data_level_out         NUM_TABLE; tableofAssocTypes_out  NUM_TABLE; tableofAssocTypeName_out STR_TABLE; tableofAssocSize_out   NUM_TABLE; plsql_type_name_out     STR_TABLE; type_subname_out        STR_TABLE; param_name_null_out    STR_TABLE; direction_null_out     NUM_TABLE; oradbtype_null_out     NUM_TABLE; size_null_out          NUM_TABLE; type_name_null_out     STR_TABLE; position_null_out      NUM_TABLE; data_level_null_out    NUM_TABLE; tableofAssocTypes_null_out NUM_TABLE; tableofAssocTypeName_null_out STR_TABLE; tableofAssocSize_null_out   NUM_TABLE; plsql_type_name_null_out     STR_TABLE; type_subname_null_out        STR_TABLE; BEGIN name_in := :1; param_count_in := :2; link := NULL; DBMS_UTILITY.NAME_RESOLVE( name_in, context, schema, part1, part2, dblink, part1_type, object_number); WHILE (dblink IS NOT NULL) LOOP link := '@' || dblink; name_in := NULL; IF (schema IS NOT NULL) THEN name_in := '\"' || schema || '\"' || '.'; END IF; IF (part1 IS NOT NULL) THEN name_in := name_in || '\"' || part1 || '\"' || '.'; END IF; IF (part2 IS NULL) THEN name_in := RTRIM(name_in, '.'); ELSE name_in := name_in || '\"' || part2 || '\"'; END IF; EXECUTE IMMEDIATE 'BEGIN DBMS_UTILITY.NAME_RESOLVE' || link || '(:1, :2, :3, :4, :5, :6, :7, :8); END;' USING name_in, context, OUT schema, OUT part1, OUT part2, OUT dblink, OUT part1_type, OUT object_number; END LOOP; IF (param_count_out = 0) THEN OPEN refcur FOR 'SELECT  DECODE (POSITION, 0, ''RETURN_VALUE'', ARGUMENT_NAME) param_name, DECODE(IN_OUT, ''IN'', \t  1,  ''IN/OUT'', 3, ''OUT'', DECODE(ARGUMENT_NAME, NULL, 6, 2), 1) direction, DECODE(DATA_TYPE, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(DATA_TYPE, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (TYPE_OWNER ||  DECODE(TYPE_OWNER, NULL, NULL, ''.'') ||  TYPE_NAME ) type_name, TYPE_SUBNAME typesubname, POSITION   position, DATA_LEVEL data_level FROM ALL_ARGUMENTS' || link || ' WHERE OWNER \t\t  = :1 \t  AND (PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND PACKAGE_NAME is null)) AND OBJECT_NAME \t  = :4 \t  AND NVL(overload, 1) = 1 ORDER BY SEQUENCE' USING schema, part1, part1, part2; FETCH refcur BULK COLLECT INTO param_name_out, direction_out, oradbtype_out, size_out, type_name_out, type_subname_out, position_out, data_level_out; param_count_out := refcur%ROWCOUNT; CLOSE refcur; END IF; IF (part1_type = 9 AND param_count_out = 0) THEN OPEN procrefcur FOR 'SELECT OBJECT_NAME FROM ALL_PROCEDURES' || link || ' WHERE OWNER = :1 AND (((OBJECT_NAME = :2) AND (PROCEDURE_NAME IS NULL)) OR ((OBJECT_NAME = :3) AND (PROCEDURE_NAME = :4)))' USING schema, part2, part1, part2; FETCH procrefcur INTO procobjectnames;proc_count := procrefcur%ROWCOUNT; CLOSE procrefcur; IF (proc_count = 0) THEN param_count_out := -1002; END IF; END IF; :3 := param_count_out; oradbtypeIndex := oradbtype_out.first; IF (oradbtypeIndex IS NOT NULL) THEN LOOP oradbtype := oradbtype_out(oradbtypeIndex); IF (oradbtype = 1) THEN has_plsqlArray := 1; END IF; oradbtypeIndex := oradbtype_out.next(oradbtypeIndex); EXIT WHEN (oradbtypeIndex IS NULL) OR (oradbtypeIndex >= param_count_out) OR (has_plsqlArray=1); END LOOP; END IF; IF (has_plsqlArray = 1) THEN OPEN plsqlrefcur FOR 'SELECT  DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (PLSQL_COLL_TYPES_SYN.ELEM_TYPE_OWNER ||  DECODE(PLSQL_COLL_TYPES_SYN.ELEM_TYPE_OWNER, NULL, NULL, ''.'') ||  PLSQL_COLL_TYPES_SYN.ELEM_TYPE_NAME ) type_name,  PLSQL_COLL_TYPES_SYN.TYPE_NAME typesubname FROM ALL_ARGUMENTS' || link || ' ARGUMENTS_SYN , ALL_PLSQL_COLL_TYPES' || link || ' PLSQL_COLL_TYPES_SYN  WHERE  ARGUMENTS_SYN.OWNER \t\t  = :1 \t  AND (ARGUMENTS_SYN.PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND ARGUMENTS_SYN.PACKAGE_NAME is null)) AND  ARGUMENTS_SYN.OBJECT_NAME \t  = :4 \t  AND  ARGUMENTS_SYN.TYPE_OWNER    = PLSQL_COLL_TYPES_SYN.OWNER AND  ARGUMENTS_SYN.TYPE_NAME     = PLSQL_COLL_TYPES_SYN.PACKAGE_NAME AND ARGUMENTS_SYN.TYPE_SUBNAME  = PLSQL_COLL_TYPES_SYN.TYPE_NAME ' USING schema, part1,part1,part2; FETCH plsqlrefcur BULK COLLECT INTO tableofAssocTypes_out, tableofAssocSize_out, tableofAssocTypeName_out, plsql_type_name_out; CLOSE plsqlrefcur; END IF; IF (param_count_out > param_count_in OR param_count_out < 0) THEN param_name_out := param_name_null_out; direction_out := direction_null_out; oradbtype_out := oradbtype_null_out; size_out      := size_null_out; type_name_out := type_name_null_out; position_out  := position_null_out; data_level_out := data_level_null_out; tableofAssocTypes_out := tableofAssocTypes_null_out; tableofAssocSize_out := tableofAssocTypes_null_out; tableofAssocTypeName_out := tableofAssocTypeName_null_out; plsql_type_name_out := plsql_type_name_null_out; type_subname_out := type_subname_null_out; END IF; :4 := param_name_out; :5 := direction_out; :6 := oradbtype_out; :7 := size_out; :8 := type_name_out; :9 := position_out; :10 := data_level_out; :11 := tableofAssocTypes_out; :12 := tableofAssocTypeName_out; :13 := tableofAssocSize_out; :14 := plsql_type_name_out; :15 := type_subname_out; END; ";
			}
			else
			{
				m_dpCommand.CommandText = "DECLARE TYPE NUM_TABLE IS TABLE OF NUMBER INDEX BY PLS_INTEGER; TYPE STR_TABLE IS TABLE OF VARCHAR2(128) INDEX BY PLS_INTEGER; name_in          VARCHAR2(2000); param_count_in   PLS_INTEGER; link\t     \t      VARCHAR2(2000); context          NUMBER := 1; schema           VARCHAR2(2000); part1            VARCHAR2(2000); part2            VARCHAR2(2000); dblink           VARCHAR2(2000); part1_type       NUMBER; object_number    NUMBER; refcur\t          SYS_REFCURSOR; idx\t\t          PLS_INTEGER := 0; proc_count       PLS_INTEGER := 0; procrefcur\t      SYS_REFCURSOR; procobjectnames  ALL_PROCEDURES.OBJECT_NAME%TYPE ; param_count_out        PLS_INTEGER := 0; param_name_out         STR_TABLE; direction_out          NUM_TABLE; oradbtype_out          NUM_TABLE; size_out               NUM_TABLE; type_name_out          STR_TABLE; position_out           NUM_TABLE; data_level_out         NUM_TABLE; param_name_null_out    STR_TABLE; direction_null_out     NUM_TABLE; oradbtype_null_out     NUM_TABLE; size_null_out          NUM_TABLE; type_name_null_out     STR_TABLE; position_null_out      NUM_TABLE; data_level_null_out    NUM_TABLE; BEGIN name_in := :1; param_count_in := :2; link := NULL; DBMS_UTILITY.NAME_RESOLVE( name_in, context, schema, part1, part2, dblink, part1_type, object_number); WHILE (dblink IS NOT NULL) LOOP link := '@' || dblink; name_in := NULL; IF (schema IS NOT NULL) THEN name_in := '\"' || schema || '\"' || '.'; END IF; IF (part1 IS NOT NULL) THEN name_in := name_in || '\"' || part1 || '\"' || '.'; END IF; IF (part2 IS NULL) THEN name_in := RTRIM(name_in, '.'); ELSE name_in := name_in || '\"' || part2 || '\"'; END IF; EXECUTE IMMEDIATE 'BEGIN DBMS_UTILITY.NAME_RESOLVE' || link || '(:1, :2, :3, :4, :5, :6, :7, :8); END;' USING name_in, context, OUT schema, OUT part1, OUT part2, OUT dblink, OUT part1_type, OUT object_number; END LOOP; IF (param_count_out = 0) THEN OPEN refcur FOR 'SELECT  DECODE (POSITION, 0, ''RETURN_VALUE'', ARGUMENT_NAME) param_name, DECODE(IN_OUT, ''IN'', \t  1,  ''IN/OUT'', 3, ''OUT'', DECODE(ARGUMENT_NAME, NULL, 6, 2), 1) direction, DECODE(DATA_TYPE, ''BINARY_DOUBLE'',  132, ''BINARY_FLOAT'',   133, ''BINARY_INTEGER'', 112, ''BFILE'',     101, ''BLOB'',\t    102, ''CHAR'',\t    104, ''CLOB'',\t    105, ''DATE'',\t    106, ''FLOAT'',\t    107, ''INTERVAL YEAR TO MONTH'', 115, ''INTERVAL DAY TO SECOND'', 114, ''LONG'',\t    109, ''LONG RAW'',\t110, ''NCHAR'',\t    117, ''NCLOB'',\t    116, ''NUMBER'',\t  107, ''NVARCHAR2'',\t119, ''PL/SQL BOOLEAN'',   134, ''RAW'',\t      120, ''REF CURSOR'',121, ''ROWID'',\t    126, ''TIMESTAMP'',\t123, ''TIMESTAMP WITH LOCAL TIME ZONE'', 124, ''TIMESTAMP WITH TIME ZONE'', 125, ''OPAQUE/XMLTYPE'', 127, ''UNDEFINED'', 100, ''UROWID'',\t  126, ''VARCHAR'', \t126, ''VARCHAR2'',\t126, ''PL/SQL TABLE'',1, NULL,            0, -1) oradbtype, DECODE(DATA_TYPE, ''CHAR'', \t      2000, ''LONG'',      32760, ''LONG RAW'',    32760, ''NCHAR'', \t    2000, ''NVARCHAR2'',   32767, ''RAW'', \t      2000, ''ROWID'', \t    4000, ''UROWID'',\t    4000, ''VARCHAR'', \t  32767, ''VARCHAR2'', \t  32767, ''PL/SQL TABLE'',  16, 0) length, (TYPE_OWNER ||  DECODE(TYPE_OWNER, NULL, NULL, ''.'') ||  TYPE_NAME ) type_name, POSITION   position, DATA_LEVEL data_level FROM ALL_ARGUMENTS' || link || ' WHERE OWNER \t\t  = :1 \t  AND (PACKAGE_NAME \t= :2 \t  OR (:3 IS NULL AND PACKAGE_NAME is null)) AND OBJECT_NAME \t  = :4 \t  AND NVL(overload, 1) = 1 ORDER BY SEQUENCE' USING schema, part1, part1, part2; FETCH refcur BULK COLLECT INTO param_name_out, direction_out, oradbtype_out, size_out, type_name_out, position_out, data_level_out; param_count_out := refcur%ROWCOUNT; CLOSE refcur; END IF; IF (part1_type = 9 AND param_count_out = 0) THEN OPEN procrefcur FOR 'SELECT OBJECT_NAME FROM ALL_PROCEDURES' || link || ' WHERE OWNER = :1 AND (((OBJECT_NAME = :2) AND (PROCEDURE_NAME IS NULL)) OR ((OBJECT_NAME = :3) AND (PROCEDURE_NAME = :4)))' USING schema, part2, part1, part2; FETCH procrefcur INTO procobjectnames;proc_count := procrefcur%ROWCOUNT; CLOSE procrefcur; IF (proc_count = 0) THEN param_count_out := -1002; END IF; END IF; :3 := param_count_out; IF (param_count_out > param_count_in OR param_count_out < 0) THEN param_name_out:= param_name_null_out; direction_out := direction_null_out; oradbtype_out := oradbtype_null_out; size_out      := size_null_out; type_name_out := type_name_null_out; position_out  := position_null_out; data_level_out:= data_level_null_out; END IF; :4 := param_name_out; :5 := direction_out; :6 := oradbtype_out; :7 := size_out; :8 := type_name_out; :9 := position_out; :10:= data_level_out; END;";
			}
			m_dpCommand.Connection = command.Connection;
			m_dpCommand.AddToStatementCache = command.AddToStatementCache;
			m_dpCommandParams[0].Value = command.CommandText;
			m_dpCommandParams[1].Value = 128;
			m_dpCommandParams[3].Size = 128;
			if (m_dpCommandParams[3].ArrayBindSize == null)
			{
				m_dpCommandParams[3].ArrayBindSize = new int[128];
			}
			for (int j = 0; j < 128; j++)
			{
				m_dpCommandParams[3].ArrayBindSize[j] = 128;
			}
			m_dpCommandParams[4].Size = 128;
			m_dpCommandParams[5].Size = 128;
			m_dpCommandParams[6].Size = 128;
			m_dpCommandParams[7].Size = 128;
			if (m_dpCommandParams[7].ArrayBindSize == null)
			{
				m_dpCommandParams[7].ArrayBindSize = new int[128];
			}
			for (int k = 0; k < 128; k++)
			{
				m_dpCommandParams[7].ArrayBindSize[k] = 128;
			}
			m_dpCommandParams[8].Size = 128;
			m_dpCommandParams[9].Size = 128;
			if (flag)
			{
				m_dpCommandParams[10].Size = 128;
				m_dpCommandParams[11].Size = 128;
				m_dpCommandParams[13].Size = 128;
				m_dpCommandParams[14].Size = 128;
				if (m_dpCommandParams[11].ArrayBindSize == null)
				{
					m_dpCommandParams[11].ArrayBindSize = new int[128];
				}
				if (m_dpCommandParams[13].ArrayBindSize == null)
				{
					m_dpCommandParams[13].ArrayBindSize = new int[128];
				}
				if (m_dpCommandParams[14].ArrayBindSize == null)
				{
					m_dpCommandParams[14].ArrayBindSize = new int[128];
				}
				for (int l = 0; l < 128; l++)
				{
					m_dpCommandParams[11].ArrayBindSize[l] = 128;
					m_dpCommandParams[13].ArrayBindSize[l] = 128;
					m_dpCommandParams[14].ArrayBindSize[l] = 128;
				}
				m_dpCommandParams[12].Size = 128;
			}
		}

		private static void PopulateCommandParamsFromDeriveParamInfo(OracleCommand command, DeriveParamInfo deriveParamInfo)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.PopulateCommandParamsFromDeriveParamInfo);
			}
			try
			{
				command.Parameters.Clear();
				for (int i = 0; i < deriveParamInfo.m_paramCount; i++)
				{
					OracleParameter oracleParameter = new OracleParameter();
					oracleParameter.ParameterName = deriveParamInfo.m_paramName[i];
					oracleParameter.Direction = deriveParamInfo.m_direction[i];
					oracleParameter.CollectionType = deriveParamInfo.m_oraCollType[i];
					oracleParameter.OracleDbTypeEx = deriveParamInfo.m_oraDbType[i];
					if (deriveParamInfo.m_size[i] != 0 && oracleParameter.Direction != ParameterDirection.Input)
					{
						oracleParameter.Size = deriveParamInfo.m_size[i];
					}
					if (oracleParameter.CollectionType == OracleCollectionType.PLSQLAssociativeArray && oracleParameter.Size > 0)
					{
						oracleParameter.ArrayBindStatus = new OracleParameterStatus[oracleParameter.Size];
						for (int j = 0; j < oracleParameter.Size; j++)
						{
							oracleParameter.ArrayBindStatus[j] = OracleParameterStatus.Success;
						}
						if (deriveParamInfo.m_arrayBindSize[i] != 0)
						{
							oracleParameter.ArrayBindSize = new int[oracleParameter.Size];
							for (int k = 0; k < oracleParameter.Size; k++)
							{
								oracleParameter.ArrayBindSize[k] = deriveParamInfo.m_arrayBindSize[i];
							}
						}
					}
					command.Parameters.Add(oracleParameter);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.PopulateCommandParamsFromDeriveParamInfo);
				}
			}
		}

		public new OracleCommand GetDeleteCommand(bool useColumnsForParameterNames)
		{
			return GetDeleteCommand();
		}

		public new OracleCommand GetInsertCommand(bool useColumnsForParameterNames)
		{
			return GetInsertCommand();
		}

		public new OracleCommand GetUpdateCommand(bool useColumnsForParameterNames)
		{
			return GetUpdateCommand();
		}

		internal OracleCommand GetInsertCommand(DataRow row)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetInsertCommand);
			}
			try
			{
				int num = 1;
				StringBuilder stringBuilder = new StringBuilder();
				StringBuilder stringBuilder2 = new StringBuilder();
				if (m_cachedInsertParams == null)
				{
					m_cachedInsertParams = new ArrayList();
				}
				if (m_insertCmd == null || m_insertCmd.m_disposed)
				{
					if (m_insertCmd != null)
					{
						int num2 = 0;
						while (num2 < m_cachedInsertParams.Count)
						{
							if (((OracleParameter)m_cachedInsertParams[0]).m_collRef != null)
							{
								m_cachedInsertParams.RemoveAt(0);
							}
							else
							{
								num2++;
							}
						}
					}
					m_insertCmd = new OracleCommand();
				}
				else
				{
					if (m_insertCmd.m_modified)
					{
						m_insertCmd.ArrayBindCount = 0;
						m_insertCmd.AddRowid = false;
						m_insertCmd.BindByName = false;
						m_insertCmd.CommandType = CommandType.Text;
						m_insertCmd.FetchSize = 131072L;
						m_insertCmd.m_initialLongFS = 0;
						m_insertCmd.CommandTimeout = 0;
					}
					m_insertCmd.Parameters.Clear();
				}
				DataTable table = row.Table;
				if (!table.ExtendedProperties.Contains("REFCursorName"))
				{
					GetBaseTableName();
				}
				else
				{
					CheckDataTable(table);
				}
				foreach (DataColumn column in table.Columns)
				{
					string columnName = GetColumnName(column, baseColumn: true);
					string columnName2 = GetColumnName(column, baseColumn: false);
					OracleDbType columnType = GetColumnType(column);
					if (columnName == null)
					{
						continue;
					}
					stringBuilder.Append(" ");
					stringBuilder.Append(columnName);
					stringBuilder.Append(",");
					if (!IsRowCurrentValueNull(row, column))
					{
						stringBuilder2.Append(" :");
						stringBuilder2.Append(num);
						stringBuilder2.Append(",");
						OracleParameter oracleParameter = null;
						if (m_cachedInsertParams.Count > num - 1)
						{
							oracleParameter = (OracleParameter)m_cachedInsertParams[num - 1];
							if (oracleParameter.m_disposed)
							{
								m_cachedInsertParams.RemoveAt(num - 1);
								oracleParameter = null;
							}
						}
						if (oracleParameter != null)
						{
							SetParam(columnName2, columnType, DataRowVersion.Current, row[column, DataRowVersion.Current], oracleParameter);
						}
						else
						{
							oracleParameter = CreateParams(null, columnName2, columnType, DataRowVersion.Current, row[column, DataRowVersion.Current]);
							m_cachedInsertParams.Insert(num - 1, oracleParameter);
						}
						m_insertCmd.Parameters.Add(oracleParameter);
						num++;
					}
					else
					{
						stringBuilder2.Append(" NULL,");
					}
				}
				if (stringBuilder.Length == 0)
				{
					return null;
				}
				StringBuilder stringBuilder3 = new StringBuilder();
				stringBuilder3.Append("INSERT INTO ");
				stringBuilder3.Append(GetSchemaName(table));
				stringBuilder3.Append(GetBaseTableName(table));
				stringBuilder3.Append("(");
				stringBuilder3.Append(stringBuilder.ToString().TrimEnd(','));
				stringBuilder3.Append(") VALUES (");
				stringBuilder3.Append(stringBuilder2.ToString().TrimEnd(','));
				stringBuilder3.Append(")");
				m_insertCmd.CommandText = stringBuilder3.ToString();
				m_insertCmd.Connection = DataAdapter.SelectCommand.Connection;
				m_insertCmd.UpdatedRowSource = UpdateRowSource.None;
				return m_insertCmd;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetInsertCommand);
				}
			}
		}

		internal OracleCommand GetUpdateCommand(DataRow row)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetUpdateCommand);
			}
			try
			{
				int num = 1;
				StringBuilder stringBuilder = new StringBuilder();
				StringBuilder stringBuilder2 = new StringBuilder();
				if (row.RowState != DataRowState.Modified)
				{
					return null;
				}
				if (m_cachedUpdateParams == null)
				{
					m_cachedUpdateParams = new ArrayList();
				}
				if (m_updateCmd == null || m_updateCmd.m_disposed)
				{
					if (m_updateCmd != null)
					{
						int num2 = 0;
						while (num2 < m_cachedUpdateParams.Count)
						{
							if (((OracleParameter)m_cachedUpdateParams[num2]).m_collRef != null)
							{
								m_cachedUpdateParams.RemoveAt(num2);
							}
							else
							{
								num2++;
							}
						}
					}
					m_updateCmd = new OracleCommand();
				}
				else
				{
					if (m_updateCmd.m_modified)
					{
						m_updateCmd.ArrayBindCount = 0;
						m_updateCmd.AddRowid = false;
						m_updateCmd.BindByName = false;
						m_updateCmd.CommandType = CommandType.Text;
						m_updateCmd.FetchSize = 131072L;
						m_updateCmd.m_initialLongFS = 0;
						m_updateCmd.CommandTimeout = 0;
					}
					m_updateCmd.Parameters.Clear();
				}
				DataTable table = row.Table;
				if (!table.ExtendedProperties.Contains("REFCursorName"))
				{
					GetBaseTableName();
				}
				else
				{
					CheckDataTable(table);
				}
				CheckPrimaryKey(row);
				foreach (DataColumn column in table.Columns)
				{
					string columnName = GetColumnName(column, baseColumn: true);
					string columnName2 = GetColumnName(column, baseColumn: false);
					OracleDbType columnType = GetColumnType(column);
					if (columnName == null || columnName.Equals("\"ROWID\"") || !IsColumnModified(row, column))
					{
						continue;
					}
					stringBuilder.Append(" ");
					stringBuilder.Append(columnName);
					stringBuilder.Append("=:");
					stringBuilder.Append(num);
					stringBuilder.Append(",");
					OracleParameter oracleParameter = null;
					if (m_cachedUpdateParams.Count > num - 1)
					{
						oracleParameter = (OracleParameter)m_cachedUpdateParams[num - 1];
						if (oracleParameter.m_disposed)
						{
							m_cachedUpdateParams.RemoveAt(num - 1);
							oracleParameter = null;
						}
					}
					if (oracleParameter != null)
					{
						SetParam(columnName2, columnType, DataRowVersion.Current, row[column, DataRowVersion.Current], oracleParameter);
					}
					else
					{
						oracleParameter = CreateParams(null, columnName2, columnType, DataRowVersion.Current, row[column, DataRowVersion.Current]);
						m_cachedUpdateParams.Insert(num - 1, oracleParameter);
					}
					m_updateCmd.Parameters.Add(oracleParameter);
					num++;
				}
				if (stringBuilder.ToString().Length == 0 && row.RowState == DataRowState.Modified)
				{
					foreach (DataColumn column2 in table.Columns)
					{
						OracleDbType columnType2 = GetColumnType(column2);
						string columnName3 = GetColumnName(column2, baseColumn: true);
						string columnName4 = GetColumnName(column2, baseColumn: false);
						if (columnName3 == null || columnName3.Equals("\"ROWID\""))
						{
							continue;
						}
						stringBuilder.Append(" ");
						stringBuilder.Append(columnName3);
						stringBuilder.Append("=:");
						stringBuilder.Append(num);
						stringBuilder.Append(",");
						OracleParameter oracleParameter2 = null;
						if (m_cachedUpdateParams.Count > num - 1)
						{
							oracleParameter2 = (OracleParameter)m_cachedUpdateParams[num - 1];
							if (oracleParameter2.m_disposed)
							{
								m_cachedUpdateParams.RemoveAt(num - 1);
								oracleParameter2 = null;
							}
						}
						if (oracleParameter2 != null)
						{
							SetParam(columnName4, columnType2, DataRowVersion.Current, row[column2, DataRowVersion.Current], oracleParameter2);
						}
						else
						{
							oracleParameter2 = CreateParams(null, columnName4, columnType2, DataRowVersion.Current, row[column2, DataRowVersion.Current]);
							m_cachedUpdateParams.Insert(num - 1, oracleParameter2);
						}
						m_updateCmd.Parameters.Add(oracleParameter2);
						num++;
					}
				}
				if (stringBuilder.ToString().Length == 0)
				{
					return null;
				}
				foreach (DataColumn column3 in table.Columns)
				{
					OracleDbType columnType3 = GetColumnType(column3);
					string columnName5 = GetColumnName(column3, baseColumn: true);
					string columnName6 = GetColumnName(column3, baseColumn: false);
					if (IsOraLOB(columnType3) || IsOraLONG(columnType3) || IsOraXmlType(columnType3) || columnName5 == null)
					{
						continue;
					}
					if (!IsRowOrigValueNull(row, column3))
					{
						stringBuilder2.Append(" ");
						if (!IsOraJson(columnType3))
						{
							stringBuilder2.Append(columnName5);
							stringBuilder2.Append("=:");
							stringBuilder2.Append(num);
						}
						else
						{
							stringBuilder2.Append($"json_equal({columnName5}, :{num})");
						}
						stringBuilder2.Append(" AND");
						OracleParameter oracleParameter3 = null;
						if (m_cachedUpdateParams.Count > num - 1)
						{
							oracleParameter3 = (OracleParameter)m_cachedUpdateParams[num - 1];
							if (oracleParameter3.m_disposed)
							{
								m_cachedUpdateParams.RemoveAt(num - 1);
								oracleParameter3 = null;
							}
						}
						if (oracleParameter3 != null)
						{
							SetParam(columnName6, columnType3, DataRowVersion.Original, row[column3, DataRowVersion.Original], oracleParameter3);
						}
						else
						{
							oracleParameter3 = CreateParams(null, columnName6, columnType3, DataRowVersion.Original, row[column3, DataRowVersion.Original]);
							m_cachedUpdateParams.Insert(num - 1, oracleParameter3);
						}
						m_updateCmd.Parameters.Add(oracleParameter3);
						num++;
					}
					else
					{
						stringBuilder2.Append(" ");
						stringBuilder2.Append(columnName5);
						stringBuilder2.Append(" IS NULL AND");
					}
				}
				StringBuilder stringBuilder3 = new StringBuilder();
				stringBuilder3.Append("UPDATE ");
				stringBuilder3.Append(GetSchemaName(table));
				stringBuilder3.Append(GetBaseTableName(table));
				stringBuilder3.Append(" SET");
				stringBuilder3.Append(stringBuilder.ToString().TrimEnd(','));
				stringBuilder3.Append(" WHERE");
				stringBuilder3.Append(stringBuilder2.ToString().TrimEnd("AND".ToCharArray()).TrimEnd());
				m_updateCmd.CommandText = stringBuilder3.ToString();
				m_updateCmd.Connection = DataAdapter.SelectCommand.Connection;
				m_updateCmd.UpdatedRowSource = UpdateRowSource.None;
				return m_updateCmd;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetUpdateCommand);
				}
			}
		}

		private bool CheckDataTable(DataTable table)
		{
			if (table.ExtendedProperties["BaseTable.1"] != null)
			{
				throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_MULTITABLE_DS));
			}
			return true;
		}

		private void SetParam(string colName, OracleDbType colType, DataRowVersion version, object value, OracleParameter param)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.SetParam);
			}
			try
			{
				if (param.m_modified)
				{
					param.Direction = ParameterDirection.Input;
					param.IsNullable = false;
					param.Offset = 0;
					param.Status = OracleParameterStatus.Success;
					param.Precision = 100;
					param.Scale = 129;
				}
				int size = -1;
				if (value != null)
				{
					string text;
					char[] array;
					byte[] array2;
					if (value is char)
					{
						size = 1;
					}
					else if ((text = value as string) != null)
					{
						size = text.Length;
					}
					else if ((array = value as char[]) != null)
					{
						size = array.Length;
					}
					else if ((array2 = value as byte[]) != null)
					{
						size = array2.Length;
					}
				}
				switch (colType)
				{
				case OracleDbType.Clob:
					if (!(value is OracleClob))
					{
						colType = OracleDbType.Varchar2;
					}
					break;
				case OracleDbType.NClob:
					if (!(value is OracleClob))
					{
						colType = OracleDbType.NVarchar2;
					}
					break;
				case OracleDbType.Blob:
					if (!(value is OracleBlob))
					{
						colType = OracleDbType.Raw;
					}
					break;
				case OracleDbType.Json:
					if (!(value is OracleString))
					{
						colType = OracleDbType.Varchar2;
					}
					break;
				}
				param.ParameterName = null;
				param.OracleDbType = colType;
				param.SetSize(size);
				param.SourceColumn = colName;
				param.SourceVersion = version;
				param.Value = value;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.SetParam);
				}
			}
		}

		private void CheckPrimaryKey()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CheckPrimaryKey);
			}
			try
			{
				if (m_sqlMetaData == null)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_NO_PRIMARYKEY));
				}
				if (!m_sqlMetaData.bPkFetched)
				{
					if (DataAdapter.SelectCommand.Connection == null || DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl == null)
					{
						throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_NO_PRIMARYKEY));
					}
					SQLMetaData.GetPrimaryKey(DataAdapter.SelectCommand.Connection, m_sqlMetaData, m_numberOfHiddenColumns, bSchemaTable: true);
				}
				if (m_sqlMetaData.m_sqlMetaInfo == null || !m_sqlMetaData.m_sqlMetaInfo.bPkPresent)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_NO_PRIMARYKEY));
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CheckPrimaryKey);
				}
			}
		}

		private void CheckPrimaryKey(DataRow row)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CheckPrimaryKey);
			}
			try
			{
				for (int i = 0; i < row.Table.Constraints.Count; i++)
				{
					if (row.Table.Constraints[i] is UniqueConstraint)
					{
						return;
					}
				}
				if (row.Table.ExtendedProperties.Contains("REFCursorName"))
				{
					if (DataAdapter == null || DataAdapter.SelectCommand == null)
					{
						goto IL_0100;
					}
					ConfigBaseClass.StoredProcedureInfo storedProcInfo = ConfigBaseClass.GetInstance(bIsManaged: true).GetStoredProcInfo(DataAdapter.SelectCommand.CommandText);
					if (storedProcInfo == null)
					{
						goto IL_0100;
					}
					string text = (string)row.Table.ExtendedProperties["REFCursorName"];
					int num = -1;
					num = ((!text.Equals("REFCursor")) ? int.Parse(text.Substring("RefCursor".Length)) : 0);
					if (num <= -1 || !storedProcInfo.GetRefCursorInfo(num).isPrimaryKeyPresent)
					{
						goto IL_0100;
					}
				}
				else
				{
					if (DataAdapter == null || DataAdapter.SelectCommand == null)
					{
						throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_NO_PRIMARYKEY));
					}
					FillSchemaMetaData();
					CheckPrimaryKey();
				}
				goto end_IL_001f;
				IL_0100:
				throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_NO_PRIMARYKEY));
				end_IL_001f:;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CheckPrimaryKey);
				}
			}
		}

		private OracleDbType GetColumnType(int col)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnType);
			}
			try
			{
				OracleDbType result = OracleDbType.Varchar2;
				bool flag = true;
				if (!FillSchemaMetaData())
				{
					return result;
				}
				ColumnDescribeInfo columnDescribeInfo = m_sqlMetaData.m_columnDescribeInfo[col];
				short dataType = columnDescribeInfo.m_dataType;
				if (dataType == 2)
				{
					int scale = columnDescribeInfo.m_scale;
					return OraDb_DbTypeTable.ConvertNumberToOraDbType(columnDescribeInfo.m_precision, scale);
				}
				result = (OracleDbType)OraDb_DbTypeTable.oraTypeToOracleDbTypeMapping[dataType];
				if (columnDescribeInfo.m_characterSetForm != 2)
				{
					flag = false;
				}
				switch (result)
				{
				case OracleDbType.Char:
					if (flag)
					{
						result = OracleDbType.NChar;
					}
					break;
				case OracleDbType.Varchar2:
					if (flag)
					{
						result = OracleDbType.NVarchar2;
					}
					break;
				case OracleDbType.Clob:
					if (flag)
					{
						result = OracleDbType.NClob;
					}
					break;
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnType);
				}
			}
		}

		private OracleDbType GetColumnType(DataColumn col)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnType);
			}
			try
			{
				OracleDbType result = OracleDbType.Varchar2;
				object obj = col.ExtendedProperties["OraDbType"];
				if (obj != null)
				{
					string s;
					result = (OracleDbType)(((s = obj as string) == null) ? ((int)(OracleDbType)obj) : int.Parse(s));
				}
				else
				{
					int num = FindBaseColumnOrdinal(col);
					if (num != -1)
					{
						result = GetColumnType(num);
					}
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnType);
				}
			}
		}

		private string GetSchemaName()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaName);
			}
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				string result = null;
				if (!FillSchemaMetaData())
				{
					return result;
				}
				result = m_sqlMetaData.m_sqlMetaInfo.m_schemaName;
				if (result != null && result.Length != 0)
				{
					if (m_caseSensitive)
					{
						stringBuilder.Append("\"");
						stringBuilder.Append(result);
						stringBuilder.Append("\"");
					}
					else
					{
						stringBuilder.Append(result);
					}
					stringBuilder.Append(".");
				}
				return stringBuilder.ToString();
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaName);
				}
			}
		}

		private string GetSchemaName(DataTable table)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaName);
			}
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				string result = null;
				object obj = table.ExtendedProperties["BaseSchema"];
				if (obj == null)
				{
					if (!FillSchemaMetaData())
					{
						return result;
					}
					result = m_sqlMetaData.m_sqlMetaInfo.m_schemaName;
				}
				else
				{
					result = (string)obj;
				}
				if (result != null && result.Length != 0)
				{
					if (m_caseSensitive)
					{
						stringBuilder.Append("\"");
						stringBuilder.Append(result);
						stringBuilder.Append("\"");
					}
					else
					{
						stringBuilder.Append(result);
					}
					stringBuilder.Append(".");
				}
				return stringBuilder.ToString();
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaName);
				}
			}
		}

		private string GetBaseTableName()
		{
			return GetBaseTableName(m_caseSensitive);
		}

		private string GetBaseTableName(bool caseSensitive)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetBaseTableName);
			}
			try
			{
				string result = null;
				if (!FillSchemaMetaData())
				{
					return result;
				}
				result = m_sqlMetaData.m_sqlMetaInfo.m_tableName;
				if (result == null)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_MULTITABLE_DS));
				}
				if (caseSensitive)
				{
					return result.Insert(result.Length, "\"").Insert(0, "\"");
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetBaseTableName);
				}
			}
		}

		private string GetBaseTableName(DataTable table)
		{
			return GetBaseTableName(table, m_caseSensitive);
		}

		private string GetBaseTableName(DataTable table, bool caseSensitive)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetBaseTableName);
			}
			try
			{
				string result = null;
				object obj = null;
				obj = table.ExtendedProperties["BaseTable.0"];
				if (obj == null)
				{
					if (!FillSchemaMetaData())
					{
						return result;
					}
					result = m_sqlMetaData.m_sqlMetaInfo.m_tableName;
				}
				else
				{
					result = (string)obj;
				}
				if (result == null)
				{
					throw new InvalidOperationException(OracleStringResourceManager.GetErrorMesg(ResourceStringConstants.BLR_MULTITABLE_DS));
				}
				if (caseSensitive)
				{
					return result.Insert(result.Length, "\"").Insert(0, "\"");
				}
				return result;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetBaseTableName);
				}
			}
		}

		private int FindBaseColumnOrdinal(DataColumn col)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.FindBaseColumnOrdinal);
			}
			try
			{
				string a = col.ColumnName;
				string tableName = col.Table.TableName;
				if (DataAdapter.TableMappings != null && DataAdapter.TableMappings.IndexOfDataSetTable(tableName) != -1)
				{
					DataTableMapping byDataSetTable = DataAdapter.TableMappings.GetByDataSetTable(tableName);
					if (byDataSetTable != null && byDataSetTable.ColumnMappings.IndexOfDataSetColumn(col.ColumnName) != -1)
					{
						DataColumnMapping byDataSetColumn = byDataSetTable.ColumnMappings.GetByDataSetColumn(col.ColumnName);
						if (byDataSetColumn != null)
						{
							a = byDataSetColumn.SourceColumn;
						}
					}
				}
				if (!FillSchemaMetaData() || m_sqlMetaData == null || m_sqlMetaData.m_columnDescribeInfo == null)
				{
					return -1;
				}
				for (int i = 0; i < m_sqlMetaData.m_columnDescribeInfo.Length; i++)
				{
					if (m_sqlMetaData.m_columnDescribeInfo[i].pColAlias != null && a == m_sqlMetaData.m_columnDescribeInfo[i].pColAlias)
					{
						return i;
					}
				}
				return -1;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.FindBaseColumnOrdinal);
				}
			}
		}

		public new OracleCommand GetDeleteCommand()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetDeleteCommand);
			}
			try
			{
				if (m_disposed)
				{
					throw new ObjectDisposedException(ToString());
				}
				if (DataAdapter == null || DataAdapter.SelectCommand == null)
				{
					throw new InvalidOperationException();
				}
				int num = 0;
				StringBuilder stringBuilder = new StringBuilder();
				string text = null;
				OracleCommand oracleCommand = new OracleCommand();
				bool flag = false;
				if (m_sqlMetaData == null || !m_sqlMetaData.bPkFetched)
				{
					if (DataAdapter.SelectCommand.Connection == null)
					{
						throw new InvalidOperationException();
					}
					if (DataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
					{
						DataAdapter.SelectCommand.Connection.Open();
						flag = true;
					}
				}
				try
				{
					FillSchemaMetaData();
					CheckPrimaryKey();
					if (DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl != null && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength > 0 && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength != m_sMaxParamNameLen)
					{
						m_sMaxParamNameLen = DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength;
					}
				}
				finally
				{
					if (flag && DataAdapter.SelectCommand.Connection.State == ConnectionState.Open)
					{
						DataAdapter.SelectCommand.Connection.Close();
					}
				}
				int noOfColumns = m_sqlMetaData.m_noOfColumns;
				int num2 = m_sMaxParamNameLen - (6 + (2 * noOfColumns).ToString().Length);
				if (num2 < 0)
				{
					num2 = 0;
				}
				bool flag2 = m_sqlMetaData.m_sqlMetaInfo != null && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo != null;
				for (int i = 0; i < noOfColumns; i++)
				{
					if (m_numberOfHiddenColumns > 0 && flag2 && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[i].m_columnName == "ROWID")
					{
						continue;
					}
					string columnName = GetColumnName(i, baseColumn: true);
					string columnName2 = GetColumnName(i, baseColumn: false);
					OracleDbType columnType = GetColumnType(i);
					if (IsOraLOB(columnType) || IsOraLONG(columnType) || IsOraXmlType(columnType) || columnName == null)
					{
						continue;
					}
					bool isNullAllowed = m_sqlMetaData.m_columnDescribeInfo[i].m_isNullAllowed;
					if (isNullAllowed)
					{
						if (m_ODTDesignMode)
						{
							text = GenerateParameterName(":ori_", num2, columnName2, num);
							stringBuilder.Append(" ((");
							stringBuilder.Append(text);
							stringBuilder.Append(" IS NULL AND ");
							stringBuilder.Append(columnName);
							stringBuilder.Append(" IS NULL) OR");
							oracleCommand.Parameters.Add(CreateParams(text, columnName2, columnType, DataRowVersion.Original, 1));
						}
						else
						{
							text = GenerateParameterName(":ind_", num2, columnName2, num);
							stringBuilder.Append(" ((");
							stringBuilder.Append(text);
							stringBuilder.Append(" = 1 AND ");
							stringBuilder.Append(columnName);
							stringBuilder.Append(" IS NULL) OR");
							oracleCommand.Parameters.Add(CreateParams(text, null, OracleDbType.Int32, DataRowVersion.Current, 1));
						}
						num++;
					}
					text = GenerateParameterName(":ori_", num2, columnName2, num);
					stringBuilder.Append(" ");
					if (!IsOraJson(columnType))
					{
						stringBuilder.Append(columnName);
						stringBuilder.Append("=");
						stringBuilder.Append(text);
					}
					else
					{
						stringBuilder.Append($"json_equal({columnName}, {text})");
					}
					if (isNullAllowed)
					{
						stringBuilder.Append(")");
					}
					stringBuilder.Append(" AND");
					DataRowVersion version = DataRowVersion.Original;
					oracleCommand.Parameters.Add(CreateParams(text, columnName2, columnType, version, null));
					num++;
				}
				StringBuilder stringBuilder2 = new StringBuilder();
				stringBuilder2.Append("DELETE FROM ");
				stringBuilder2.Append(GetSchemaName());
				stringBuilder2.Append(GetBaseTableName());
				stringBuilder2.Append(" WHERE");
				stringBuilder2.Append(stringBuilder.ToString().TrimEnd("AND".ToCharArray()).TrimEnd());
				oracleCommand.CommandText = stringBuilder2.ToString();
				oracleCommand.Connection = DataAdapter.SelectCommand.Connection;
				oracleCommand.UpdatedRowSource = UpdateRowSource.None;
				return oracleCommand;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetDeleteCommand, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetDeleteCommand);
				}
			}
		}

		private bool FillSchemaMetaData()
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.FillSchemaMetaData);
			}
			try
			{
				if (DataAdapter == null || DataAdapter.SelectCommand == null)
				{
					throw new InvalidOperationException();
				}
				if (m_sqlMetaData == null || !m_sqlMetaData.bGotDescribeInfoFromDB)
				{
					if (DataAdapter.SelectCommand.Connection == null || DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl == null || string.IsNullOrWhiteSpace(DataAdapter.SelectCommand.CommandText))
					{
						throw new InvalidOperationException();
					}
					m_sqlMetaData = DataAdapter.SelectCommand.DoDescribeSelectQuery(out m_numberOfHiddenColumns);
				}
				if (m_sqlMetaData != null && !m_sqlMetaData.bStmtParsed)
				{
					if (DataAdapter.SelectCommand.Connection == null || DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl == null)
					{
						throw new InvalidOperationException();
					}
					SQLParser.GetSchemaMetaData(m_sqlMetaData, DataAdapter.SelectCommand.Connection, DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl, m_numberOfHiddenColumns > 0);
				}
				return m_sqlMetaData != null;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.FillSchemaMetaData);
				}
			}
		}

		internal OracleCommand GetDeleteCommand(DataRow row)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetDeleteCommand);
			}
			try
			{
				int num = 1;
				StringBuilder stringBuilder = new StringBuilder();
				DataTable table = row.Table;
				if (!table.ExtendedProperties.Contains("REFCursorName"))
				{
					GetBaseTableName();
				}
				else
				{
					CheckDataTable(table);
				}
				CheckPrimaryKey(row);
				if (m_cachedDeleteParams == null)
				{
					m_cachedDeleteParams = new ArrayList();
				}
				if (m_deleteCmd == null || m_deleteCmd.m_disposed)
				{
					if (m_deleteCmd != null)
					{
						int num2 = 0;
						while (num2 < m_cachedDeleteParams.Count)
						{
							if (((OracleParameter)m_cachedDeleteParams[num2]).m_collRef != null)
							{
								m_cachedDeleteParams.RemoveAt(num2);
							}
							else
							{
								num2++;
							}
						}
					}
					m_deleteCmd = new OracleCommand();
				}
				else
				{
					if (m_deleteCmd.m_modified)
					{
						m_deleteCmd.ArrayBindCount = 0;
						m_deleteCmd.AddRowid = false;
						m_deleteCmd.BindByName = false;
						m_deleteCmd.CommandType = CommandType.Text;
						m_deleteCmd.FetchSize = 131072L;
						m_deleteCmd.m_initialLongFS = 0;
						m_deleteCmd.CommandTimeout = 0;
					}
					m_deleteCmd.Parameters.Clear();
				}
				foreach (DataColumn column in table.Columns)
				{
					string columnName = GetColumnName(column, baseColumn: true);
					string columnName2 = GetColumnName(column, baseColumn: false);
					OracleDbType columnType = GetColumnType(column);
					if (IsOraLOB(columnType) || IsOraLONG(columnType) || IsOraXmlType(columnType) || columnName == null)
					{
						continue;
					}
					if (!IsRowOrigValueNull(row, column))
					{
						stringBuilder.Append(" ");
						if (!IsOraJson(columnType))
						{
							stringBuilder.Append(columnName);
							stringBuilder.Append("=:");
							stringBuilder.Append(num);
						}
						else
						{
							stringBuilder.Append($"json_equal({columnName}, :{num})");
						}
						stringBuilder.Append(" AND");
						DataRowVersion version = DataRowVersion.Original;
						OracleParameter oracleParameter = null;
						if (m_cachedDeleteParams.Count > num - 1)
						{
							oracleParameter = (OracleParameter)m_cachedDeleteParams[num - 1];
							if (oracleParameter.m_disposed)
							{
								m_cachedDeleteParams.RemoveAt(num - 1);
								oracleParameter = null;
							}
						}
						if (oracleParameter != null)
						{
							SetParam(columnName2, columnType, version, row[column, DataRowVersion.Original], oracleParameter);
						}
						else
						{
							oracleParameter = CreateParams(null, columnName2, columnType, version, row[column, DataRowVersion.Original]);
							m_cachedDeleteParams.Insert(num - 1, oracleParameter);
						}
						m_deleteCmd.Parameters.Add(oracleParameter);
						num++;
					}
					else
					{
						stringBuilder.Append(" ");
						stringBuilder.Append(columnName);
						stringBuilder.Append(" IS NULL AND");
					}
				}
				StringBuilder stringBuilder2 = new StringBuilder();
				stringBuilder2.Append("DELETE FROM ");
				stringBuilder2.Append(GetSchemaName(table));
				stringBuilder2.Append(GetBaseTableName(table));
				stringBuilder2.Append(" WHERE");
				stringBuilder2.Append(stringBuilder.ToString().TrimEnd("AND".ToCharArray()).TrimEnd());
				m_deleteCmd.CommandText = stringBuilder2.ToString();
				m_deleteCmd.Connection = DataAdapter.SelectCommand.Connection;
				m_deleteCmd.UpdatedRowSource = UpdateRowSource.None;
				return m_deleteCmd;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetDeleteCommand);
				}
			}
		}

		public new OracleCommand GetInsertCommand()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetInsertCommand);
			}
			try
			{
				if (m_disposed)
				{
					throw new ObjectDisposedException(ToString());
				}
				if (DataAdapter == null || DataAdapter.SelectCommand == null)
				{
					throw new InvalidOperationException();
				}
				int num = 0;
				StringBuilder stringBuilder = new StringBuilder();
				StringBuilder stringBuilder2 = new StringBuilder();
				string text = null;
				OracleCommand oracleCommand = new OracleCommand();
				bool flag = false;
				if (m_sqlMetaData == null || !m_sqlMetaData.bStmtParsed)
				{
					if (DataAdapter.SelectCommand.Connection == null)
					{
						throw new InvalidOperationException();
					}
					if (DataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
					{
						DataAdapter.SelectCommand.Connection.Open();
						flag = true;
					}
				}
				try
				{
					FillSchemaMetaData();
					if (DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl != null && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength > 0 && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength != m_sMaxParamNameLen)
					{
						m_sMaxParamNameLen = DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength;
					}
				}
				finally
				{
					if (flag && DataAdapter.SelectCommand.Connection.State == ConnectionState.Open)
					{
						DataAdapter.SelectCommand.Connection.Close();
					}
				}
				if (m_sqlMetaData == null)
				{
					return null;
				}
				int noOfColumns = m_sqlMetaData.m_noOfColumns;
				int num2 = noOfColumns;
				int num3 = m_sMaxParamNameLen - (6 + num2.ToString().Length);
				if (num3 < 0)
				{
					num3 = 0;
				}
				bool flag2 = m_sqlMetaData.m_sqlMetaInfo != null && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo != null;
				for (int i = 0; i < noOfColumns; i++)
				{
					if (!flag2 || (m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[i].Updatable && (m_numberOfHiddenColumns <= 0 || !(m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[i].m_columnName == "ROWID"))))
					{
						OracleDbType columnType = GetColumnType(i);
						string columnName = GetColumnName(i, baseColumn: true);
						string columnName2 = GetColumnName(i, baseColumn: false);
						if (columnName != null)
						{
							stringBuilder.Append(" ");
							stringBuilder.Append(columnName);
							stringBuilder.Append(",");
							text = GenerateParameterName(":cur_", num3, columnName2, num);
							stringBuilder2.Append(" ");
							stringBuilder2.Append(text);
							stringBuilder2.Append(",");
							oracleCommand.Parameters.Add(CreateParams(text, columnName2, columnType, DataRowVersion.Current, null));
							num++;
						}
					}
				}
				if (stringBuilder.Length == 0)
				{
					return null;
				}
				StringBuilder stringBuilder3 = new StringBuilder();
				stringBuilder3.Append("INSERT INTO ");
				stringBuilder3.Append(GetSchemaName());
				stringBuilder3.Append(GetBaseTableName());
				stringBuilder3.Append("(");
				stringBuilder3.Append(stringBuilder.ToString().TrimEnd(','));
				stringBuilder3.Append(") VALUES (");
				stringBuilder3.Append(stringBuilder2.ToString().TrimEnd(','));
				stringBuilder3.Append(")");
				oracleCommand.CommandText = stringBuilder3.ToString();
				oracleCommand.Connection = DataAdapter.SelectCommand.Connection;
				oracleCommand.UpdatedRowSource = UpdateRowSource.None;
				return oracleCommand;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetInsertCommand, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetInsertCommand);
				}
			}
		}

		public new OracleCommand GetUpdateCommand()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetUpdateCommand);
			}
			try
			{
				if (m_disposed)
				{
					throw new ObjectDisposedException(ToString());
				}
				if (DataAdapter == null || DataAdapter.SelectCommand == null)
				{
					throw new InvalidOperationException();
				}
				int num = 0;
				StringBuilder stringBuilder = new StringBuilder();
				StringBuilder stringBuilder2 = new StringBuilder();
				string text = null;
				OracleCommand oracleCommand = new OracleCommand();
				bool flag = false;
				if (m_sqlMetaData == null || !m_sqlMetaData.bPkFetched)
				{
					if (DataAdapter.SelectCommand.Connection == null)
					{
						throw new InvalidOperationException();
					}
					if (DataAdapter.SelectCommand.Connection.State == ConnectionState.Closed)
					{
						DataAdapter.SelectCommand.Connection.Open();
						flag = true;
					}
				}
				try
				{
					FillSchemaMetaData();
					CheckPrimaryKey();
					if (DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl != null && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength > 0 && DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength != m_sMaxParamNameLen)
					{
						m_sMaxParamNameLen = DataAdapter.SelectCommand.Connection.m_oracleConnectionImpl.m_maxIdentifierLength;
					}
				}
				finally
				{
					if (flag && DataAdapter.SelectCommand.Connection.State == ConnectionState.Open)
					{
						DataAdapter.SelectCommand.Connection.Close();
					}
				}
				int noOfColumns = m_sqlMetaData.m_noOfColumns;
				int num2 = m_sMaxParamNameLen - (6 + (3 * noOfColumns).ToString().Length);
				if (num2 < 0)
				{
					num2 = 0;
				}
				bool flag2 = m_sqlMetaData.m_sqlMetaInfo != null && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo != null;
				for (int i = 0; i < noOfColumns; i++)
				{
					if (!flag2 || (m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[i].Updatable && (m_numberOfHiddenColumns <= 0 || !(m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[i].m_columnName == "ROWID"))))
					{
						OracleDbType columnType = GetColumnType(i);
						string columnName = GetColumnName(i, baseColumn: true);
						string columnName2 = GetColumnName(i, baseColumn: false);
						if (columnName != null)
						{
							text = GenerateParameterName(":cur_", num2, columnName2, num);
							stringBuilder.Append(" ");
							stringBuilder.Append(columnName);
							stringBuilder.Append("=");
							stringBuilder.Append(text);
							stringBuilder.Append(",");
							oracleCommand.Parameters.Add(CreateParams(text, columnName2, columnType, DataRowVersion.Current, null));
							num++;
						}
					}
				}
				if (stringBuilder.ToString().Length == 0)
				{
					return null;
				}
				for (int j = 0; j < noOfColumns; j++)
				{
					OracleDbType columnType2 = GetColumnType(j);
					string columnName3 = GetColumnName(j, baseColumn: true);
					string columnName4 = GetColumnName(j, baseColumn: false);
					if ((flag2 && m_numberOfHiddenColumns > 0 && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[j].m_columnName == "ROWID") || IsOraLOB(columnType2) || IsOraLONG(columnType2) || IsOraXmlType(columnType2) || columnName3 == null)
					{
						continue;
					}
					bool isNullAllowed = m_sqlMetaData.m_columnDescribeInfo[j].m_isNullAllowed;
					if (isNullAllowed)
					{
						if (m_ODTDesignMode)
						{
							text = GenerateParameterName(":ori_", num2, columnName4, num);
							stringBuilder2.Append(" ((");
							stringBuilder2.Append(text);
							stringBuilder2.Append(" IS NULL AND ");
							stringBuilder2.Append(columnName3);
							stringBuilder2.Append(" IS NULL) OR");
							oracleCommand.Parameters.Add(CreateParams(text, columnName4, columnType2, DataRowVersion.Original, 1));
						}
						else
						{
							text = GenerateParameterName(":ind_", num2, columnName4, num);
							stringBuilder2.Append(" ((");
							stringBuilder2.Append(text);
							stringBuilder2.Append(" = 1 AND ");
							stringBuilder2.Append(columnName3);
							stringBuilder2.Append(" IS NULL) OR");
							oracleCommand.Parameters.Add(CreateParams(text, null, OracleDbType.Int32, DataRowVersion.Current, 1));
						}
						num++;
					}
					text = GenerateParameterName(":ori_", num2, columnName4, num);
					stringBuilder2.Append(" ");
					if (!IsOraJson(columnType2))
					{
						stringBuilder2.Append(columnName3);
						stringBuilder2.Append("=");
						stringBuilder2.Append(text);
					}
					else
					{
						stringBuilder2.Append($"json_equal({columnName3}, {text})");
					}
					if (isNullAllowed)
					{
						stringBuilder2.Append(")");
					}
					stringBuilder2.Append(" AND");
					oracleCommand.Parameters.Add(CreateParams(text, columnName4, columnType2, DataRowVersion.Original, null));
					num++;
				}
				StringBuilder stringBuilder3 = new StringBuilder();
				stringBuilder3.Append("UPDATE ");
				stringBuilder3.Append(GetSchemaName());
				stringBuilder3.Append(GetBaseTableName());
				stringBuilder3.Append(" SET");
				stringBuilder3.Append(stringBuilder.ToString().TrimEnd(','));
				stringBuilder3.Append(" WHERE");
				stringBuilder3.Append(stringBuilder2.ToString().TrimEnd("AND".ToCharArray()).TrimEnd());
				oracleCommand.CommandText = stringBuilder3.ToString();
				oracleCommand.Connection = DataAdapter.SelectCommand.Connection;
				oracleCommand.UpdatedRowSource = UpdateRowSource.None;
				return oracleCommand;
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetUpdateCommand, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetUpdateCommand);
				}
			}
		}

		public override string QuoteIdentifier(string unquotedIdentifier)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.QuoteIdentifier);
			}
			try
			{
				if (unquotedIdentifier == null)
				{
					throw new ArgumentNullException();
				}
				if (unquotedIdentifier.Length == 0)
				{
					return QuotePrefix + QuoteSuffix;
				}
				return string.Format("{0}{1}{2}", QuotePrefix, unquotedIdentifier.Replace("\"", "\"\""), QuoteSuffix);
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.QuoteIdentifier, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.QuoteIdentifier);
				}
			}
		}

		public override string UnquoteIdentifier(string quotedIdentifier)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.UnquoteIdentifier);
			}
			try
			{
				if (quotedIdentifier == null)
				{
					throw new ArgumentNullException();
				}
				int length = quotedIdentifier.Length;
				if (length < 2 || quotedIdentifier[0] != '"' || quotedIdentifier[length - 1] != '"')
				{
					throw new ArgumentException();
				}
				return quotedIdentifier.Substring(1, length - 2).Replace("\"\"", "\"");
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.UnquoteIdentifier, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.UnquoteIdentifier);
				}
			}
		}

		public override void RefreshSchema()
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.RefreshSchema);
			}
			try
			{
				if (DataAdapter != null)
				{
					m_sqlMetaData = null;
				}
				base.RefreshSchema();
			}
			catch (Exception ex)
			{
				OracleException.HandleError(OracleTraceLevel.Public, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.RefreshSchema, ex);
				throw;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.RefreshSchema);
				}
			}
		}

		protected override void ApplyParameterInfo(DbParameter parameter, DataRow row, StatementType statementType, bool whereClause)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ApplyParameterInfo);
			}
			try
			{
				OracleParameter oracleParameter = parameter as OracleParameter;
				if (oracleParameter != null)
				{
					oracleParameter.OracleDbType = (OracleDbType)row["ProviderType"];
					oracleParameter.IsNullable = (bool)row["AllowDBNull"];
					oracleParameter.Size = (int)row["ColumnSize"];
					oracleParameter.SourceColumn = (string)row["ColumnName"];
					object obj = row["NumericScale"];
					if (obj != null && obj != DBNull.Value)
					{
						oracleParameter.Scale = (byte)(short)obj;
					}
					obj = row["NumericPrecision"];
					if (obj != null && obj != DBNull.Value)
					{
						oracleParameter.Precision = (byte)(short)obj;
					}
					if (ParameterDirection.Input == oracleParameter.Direction && parameter.Size == 0)
					{
						(parameter as OracleParameter).SetSize(-1);
					}
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.ApplyParameterInfo);
				}
			}
		}

		private bool IsOraLOB(OracleDbType colType)
		{
			if (colType != OracleDbType.Blob && colType != OracleDbType.Clob && colType != OracleDbType.NClob)
			{
				return colType == OracleDbType.BFile;
			}
			return true;
		}

		private bool IsOraLONG(OracleDbType colType)
		{
			if (colType != OracleDbType.Long)
			{
				return colType == OracleDbType.LongRaw;
			}
			return true;
		}

		private bool IsOraXmlType(OracleDbType colType)
		{
			return colType == OracleDbType.XmlType;
		}

		private bool IsOraJson(OracleDbType colType)
		{
			return colType == OracleDbType.Json;
		}

		private bool IsRowOrigValueNull(DataRow row, DataColumn col)
		{
			object obj = row[col, DataRowVersion.Original];
			if (obj != DBNull.Value)
			{
				if (obj is INullable)
				{
					return (obj as INullable).IsNull;
				}
				return false;
			}
			return true;
		}

		private string GenerateParameterName(string prefix, int srcColumnLen, string srcColumn, int paramId)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.IsRowOrigValueNull);
			}
			try
			{
				string text = Regex.Replace(srcColumn, "[^\\w]", "");
				int byteCount = Encoding.UTF8.GetByteCount(text);
				if (srcColumnLen < byteCount)
				{
					char[] array = text.ToCharArray();
					int num = 0;
					int num2 = 0;
					StringBuilder stringBuilder = new StringBuilder(srcColumnLen);
					char[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						char value = array2[i];
						num = Encoding.UTF8.GetByteCount(value.ToString());
						if (num2 + num > srcColumnLen)
						{
							break;
						}
						stringBuilder.Append(value);
						num2 += num;
					}
					if (stringBuilder.Length > 0)
					{
						text = stringBuilder.ToString();
					}
				}
				StringBuilder stringBuilder2 = new StringBuilder(128);
				stringBuilder2.Append(prefix);
				stringBuilder2.Append(text);
				stringBuilder2.Append("_p");
				stringBuilder2.Append(paramId);
				return stringBuilder2.ToString();
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.IsRowOrigValueNull);
				}
			}
		}

		private OracleParameter CreateParams(string paramName, string colName, OracleDbType colType, DataRowVersion version, object value)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CreateParams);
			}
			try
			{
				int size = -1;
				if (value != null)
				{
					string text;
					char[] array;
					byte[] array2;
					if (value is char)
					{
						size = 1;
					}
					else if ((text = value as string) != null)
					{
						size = text.Length;
					}
					else if ((array = value as char[]) != null)
					{
						size = array.Length;
					}
					else if ((array2 = value as byte[]) != null)
					{
						size = array2.Length;
					}
				}
				switch (colType)
				{
				case OracleDbType.Clob:
					if (!(value is OracleClob))
					{
						colType = OracleDbType.Varchar2;
					}
					break;
				case OracleDbType.NClob:
					if (!(value is OracleClob))
					{
						colType = OracleDbType.NVarchar2;
					}
					break;
				case OracleDbType.Blob:
					if (!(value is OracleBlob))
					{
						colType = OracleDbType.Raw;
					}
					break;
				case OracleDbType.Json:
					if (!(value is OracleString))
					{
						colType = OracleDbType.Varchar2;
					}
					break;
				}
				return new OracleParameter(paramName, colType, size, colName, version, value)
				{
					m_modified = false
				};
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.CreateParams);
				}
			}
		}

		protected override DbCommand InitializeCommand(DbCommand command)
		{
			return base.InitializeCommand(command);
		}

		protected override string GetParameterName(int parameterOrdinal)
		{
			return "p" + parameterOrdinal;
		}

		protected override string GetParameterName(string parameterName)
		{
			return parameterName;
		}

		protected override string GetParameterPlaceholder(int parameterOrdinal)
		{
			return ":p" + parameterOrdinal;
		}

		protected override DataTable GetSchemaTable(DbCommand srcCommand)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaTable);
			}
			try
			{
				return (srcCommand as OracleCommand).ExecuteReader(CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo).GetSchemaTable();
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetSchemaTable);
				}
			}
		}

		protected override void SetRowUpdatingHandler(DbDataAdapter adapter)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.SetRowUpdatingHandler);
			}
			try
			{
				if (adapter == null)
				{
					throw new ArgumentNullException();
				}
				if (DataAdapter == adapter)
				{
					((OracleDataAdapter)adapter).RowUpdating -= m_handler;
				}
				else
				{
					((OracleDataAdapter)adapter).RowUpdating += m_handler;
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.SetRowUpdatingHandler);
				}
			}
		}

		private void RowUpdating(object src, OracleRowUpdatingEventArgs arg)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.RowUpdating);
			}
			DataRow row = arg.Row;
			try
			{
				switch (arg.StatementType)
				{
				case StatementType.Delete:
				{
					if (DataAdapter.DeleteCommand == null)
					{
						arg.Command = GetDeleteCommand(row);
						break;
					}
					int count2 = arg.Command.Parameters.Count;
					for (int j = 0; j < count2 - 1; j++)
					{
						OracleParameter oracleParameter2 = arg.Command.Parameters[j];
						if (oracleParameter2.SourceColumn.Length == 0)
						{
							object value2 = arg.Command.Parameters[j + 1].Value;
							if (value2 == DBNull.Value || (value2 is INullable && (value2 as INullable).IsNull))
							{
								oracleParameter2.Value = 1;
							}
							else
							{
								oracleParameter2.Value = 0;
							}
						}
					}
					break;
				}
				case StatementType.Insert:
					if (DataAdapter.InsertCommand == null)
					{
						arg.Command = GetInsertCommand(row);
					}
					break;
				case StatementType.Update:
				{
					if (DataAdapter.UpdateCommand == null)
					{
						arg.Command = GetUpdateCommand(row);
						break;
					}
					int count = arg.Command.Parameters.Count;
					for (int i = 0; i < count - 1; i++)
					{
						OracleParameter oracleParameter = arg.Command.Parameters[i];
						if (oracleParameter.SourceColumn.Length == 0)
						{
							object value = arg.Command.Parameters[i + 1].Value;
							if (value == DBNull.Value || (value is INullable && (value as INullable).IsNull))
							{
								oracleParameter.Value = 1;
							}
							else
							{
								oracleParameter.Value = 0;
							}
						}
					}
					break;
				}
				default:
					throw new ArgumentException();
				}
			}
			catch (Exception ex)
			{
				row.RowError = ex.Message;
				if (!DataAdapter.ContinueUpdateOnError)
				{
					throw;
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.RowUpdating);
				}
			}
		}

		private string GetColumnName(DataColumn col, bool baseColumn)
		{
			return GetColumnName(col, baseColumn, m_caseSensitive);
		}

		private string GetColumnName(int col, bool baseColumn)
		{
			return GetColumnName(col, baseColumn, m_caseSensitive);
		}

		private string GetColumnName(int col, bool baseColumn, bool caseSensitive)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnName);
			}
			try
			{
				string text = null;
				if (baseColumn)
				{
					if (m_sqlMetaData.m_sqlMetaInfo != null && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo != null)
					{
						text = m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[col].m_columnName;
					}
				}
				else
				{
					text = m_sqlMetaData.m_columnDescribeInfo[col].pColAlias;
				}
				if (text != null && caseSensitive && baseColumn)
				{
					return text.Insert(text.Length, "\"").Insert(0, "\"");
				}
				return text;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnName);
				}
			}
		}

		private string GetColumnName(DataColumn col, bool baseColumn, bool caseSensitive)
		{
			if (ProviderConfig.m_bTraceLevelPrivate)
			{
				Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnName);
			}
			try
			{
				int num = 0;
				string text = (string)col.ExtendedProperties["BaseColumn"];
				if (text == null || !baseColumn)
				{
					num = FindBaseColumnOrdinal(col);
					if (num == -1)
					{
						return null;
					}
					if (baseColumn)
					{
						if (m_sqlMetaData.m_sqlMetaInfo != null && m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo != null && !m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[num].bIsExpression)
						{
							text = m_sqlMetaData.m_sqlMetaInfo.m_columnMetaInfo[num].m_columnName;
						}
					}
					else
					{
						text = m_sqlMetaData.m_columnDescribeInfo[num].pColAlias;
					}
				}
				if (text != null && m_caseSensitive && baseColumn)
				{
					return text.Insert(text.Length, "\"").Insert(0, "\"");
				}
				return text;
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.GetColumnName);
				}
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (ProviderConfig.m_bTraceLevelPublic)
			{
				Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Entry, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.Dispose);
			}
			try
			{
				if (m_disposed)
				{
					return;
				}
				try
				{
					if (disposing)
					{
						m_deleteCmd = null;
						m_insertCmd = null;
						m_updateCmd = null;
						if (DataAdapter != null)
						{
							try
							{
								DataAdapter.RowUpdating -= m_handler;
							}
							catch
							{
							}
						}
						if (m_cachedInsertParams != null)
						{
							try
							{
								m_cachedInsertParams.Clear();
							}
							catch
							{
							}
							m_cachedInsertParams = null;
						}
						if (m_cachedUpdateParams != null)
						{
							try
							{
								m_cachedUpdateParams.Clear();
							}
							catch
							{
							}
							m_cachedUpdateParams = null;
						}
						if (m_cachedDeleteParams != null)
						{
							try
							{
								m_cachedDeleteParams.Clear();
							}
							catch
							{
							}
							m_cachedDeleteParams = null;
						}
					}
					m_disposed = true;
				}
				finally
				{
					try
					{
						base.Dispose(disposing);
					}
					catch
					{
					}
				}
			}
			catch (Exception ex)
			{
				if (ProviderConfig.m_bTraceLevelPrivate)
				{
					Trace.Write(OracleTraceLevel.Private, OracleTraceTag.Error, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.Dispose, ex.Message);
				}
			}
			finally
			{
				if (ProviderConfig.m_bTraceLevelPublic)
				{
					Trace.Write(OracleTraceLevel.Public, OracleTraceTag.Exit, OracleTraceClassName.OracleCommandBuilder, OracleTraceFuncName.Dispose);
				}
			}
		}

		private bool IsRowCurrentValueNull(DataRow row, DataColumn col)
		{
			object obj = row[col, DataRowVersion.Current];
			if (obj != DBNull.Value)
			{
				if (obj is INullable)
				{
					return (obj as INullable).IsNull;
				}
				return false;
			}
			return true;
		}

		private bool IsColumnModified(DataRow row, DataColumn col)
		{
			return !row[col, DataRowVersion.Current].Equals(row[col, DataRowVersion.Original]);
		}
	}
}
